export default function getQueryString(paras) {
  var paraString = window.location.hash.split('?')[1];
  var paraObj = {}
  if (paraString && paraString.split('&').length) {
    paraString.split('&').forEach((query) => {
      if (query.split('=').length) paraObj[query.split('=')[0]] = query.split('=')[1];
    });
  }
  if (paras) {
    var returnValue = paraObj[paras];
    if (typeof (returnValue) == "undefined") {
      return "";
    } else {
      return returnValue;
    }
  } else {
    return paraObj;
  }
}
export function stringLess(str, maxlength) {
  if (str.length && str.length > maxlength) {
    return `${str.substring(0, maxlength - 3)}...`;
  }
  return str;
}

export function getName(str, splitFlag = '@#') {
  if (str && str.split(splitFlag) > 1) {
    return str.split(splitFlag)[1];
  }
  return str;
}

export function repeat(target, n) {
  var s = target, total = "";
  while (n > 0) {
    if (n % 2 == 1) {
      total += s;
    }
    if (n == 1) {
      break;
    }
    s += s;
    n = n >> 1;
  }
  return total;
}
